package drawing 
{
	import core.IDisposable;
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import furnitures.FurnitureModel;
	import resources.Images;
	/**
	 * ...
	 * @author Dmitriy Gaiduk
	 */
	
	/**
	 *  Fill with color
	 */
	public class ColorPalette implements IPaletteDisposable
	{
		private var _color:uint;
		private var _alpha:Number = 1;
		
		private var _glassColor:uint = 0xCCFFF4;
		
		private var _lineThikness:Number = 2;
		private var _lineColor:uint = 0x000000;
		public function ColorPalette(initColor:uint = 0x000000, alpha:Number = 1) 
		{
			_color = initColor;
			_alpha = alpha;
		}
		
		/* INTERFACE draw.IPalette */
		
		public function beginFill(surface:Graphics, brushType:String,
									surfaceWidth:Number, surfaceHeight:Number,
									reverseByX:Boolean = false,
									reverseByY:Boolean = false):Boolean
		{
			var fillTexture:BitmapData = null;
			
			switch(brushType) {
				case FurnitureModel.EXTRA_GRID:
						fillTexture = Images.getImageBitmap(Images.GRID);
					break;
				case FurnitureModel.EXTRA_GLASS:
						fillTexture = Images.getImageBitmap(Images.GLASS);
					break;

			}
			
			if (fillTexture != null) {
				surface.lineStyle(1, 0x000000);
				surface.beginBitmapFill(fillTexture, null, true, true);
				
			}else {
				if (_lineThikness > 0)
				{
					
					surface.lineStyle(_lineThikness, _lineColor);
				}else
				{
					surface.lineStyle();
				}
				surface.beginFill(color, _alpha);
			}
			
			return true;
		}
		
		public function lineStyle(surface:Graphics):Boolean
		{
			surface.lineStyle(10, 0x000000);
			return true;
		}
		
		
		public function endFill(surface:Graphics):void 
		{
			surface.endFill();
		}
		
		
		/* end INTERFACE draw.IPalette */
		
		public function get color():uint 
		{
			return _color;
		}
		
		public function set color(value:uint):void 
		{
			_color = value;
		}
		
		public function get lineThikness():Number 
		{
			return _lineThikness;
		}
		
		public function set lineThikness(value:Number):void 
		{
			_lineThikness = value;
		}
		
		public function get lineColor():Number 
		{
			return _lineColor;
		}
		
		public function set lineColor(value:Number):void 
		{
			_lineColor = value;
		}
		
		public function get alpha():Number 
		{
			return _alpha;
		}
		
	
		
		
		/* INTERFACE core.IDisposable */
		
		public function dispose():void 
		{
			
		}
		
	}

}